#include <iostream>
#include <string.h>

#include "range_file.h"

using namespace std;

int main()
{
    char data[] = "123456789abcdefgh";
    const char *filename = "aaa.txt";
    const char *download_filename = "bbb.txt";

    size_t end = uploadfile(filename, 0, data, 5);
    end = uploadfile("aaa.txt", end, data + end, 2);
    end = uploadfile("aaa.txt", end, data + end, 3);
    int remain = strlen(data) - end;
    uploadfile("aaa.txt", end, data + end, remain);

    //
    size_t write_end = downloadfile(filename, download_filename, 0, 3);
    write_end = downloadfile(filename, download_filename, write_end, 4);
    write_end = downloadfile(filename, download_filename, write_end, 2);
    write_end = downloadfile(filename, download_filename, write_end, 22);
    cout << write_end <<endl;

    return 0;
}
